package com.lak.nagivation.cal;

import java.net.URL;

public class AmapServer {
    private static String KEY = "c8972612f3e5098680401c5f827a739f";
    private static String HeadOfDriving = "https://restapi.amap.com/v3/direction/driving?";
    private static String HeadOfGeocode = "https://restapi.amap.com/v3/geocode/geo?";
    private static String HeadOfSearchPOI="https://restapi.amap.com/v3/place/text?";


    /**
     * 发送高德服务请求
     * @param URL  请求地址
     * @return java.lang.String
     * @author jiang
     * @creed: Good good study,day day up!
     * @date 2020/9/16 19:33
     */
    public static String requestULR(String URL){
        String res = "";
        try {
            java.net.URL url = new URL(URL);
            java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("GET");
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            while ((line = in.readLine()) != null) {
                res += line + "\n";
            }
            in.close();
        } catch (Exception e) {
            System.out.println("error :" + e.getMessage());
        }
        return res;
    }
    public static String getKEY() {
        return KEY;
    }

    public static void setKEY(String KEY) {
        AmapServer.KEY = KEY;
    }

    public static String getHeadOfDriving() {
        return HeadOfDriving;
    }

    public static void setHeadOfDriving(String headOfDriving) {
        HeadOfDriving = headOfDriving;
    }

    public static String getHeadOfGeocode() {
        return HeadOfGeocode;
    }

    public static void setHeadOfGeocode(String headOfGeocode) {
        HeadOfGeocode = headOfGeocode;
    }

    public static String getHeadOfSearchPOI() {
        return HeadOfSearchPOI;
    }

    public static void setHeadOfSearchPOI(String headOfSearchPOI) {
        HeadOfSearchPOI = headOfSearchPOI;
    }
}
